package com.hx_ai.nlp.simple.utils;

import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.*;

import static sun.font.FontUtilities.isWindows;

/**
 * Created by dzkan on 2016/11/19.
 * 收音机属性
 */
@Getter
@Slf4j
public class RadioProperties {
    private Map<String, List<String>> radios;
    private Map<String, List<String>> operations;

    private void setupRadios() {
        radios = new HashMap<>();
        List<String> lines = new ArrayList<>();

        Charset charset = StandardCharsets.UTF_8;
        if (isWindows){
            charset = StandardCharsetsNew.GBK;
        }

        try {
            InputStreamLoadUtils.inputSteamLoad("/radio.txt", charset, lines);
            if (!lines.isEmpty()){
                for (String line : lines) {
                    String[] radio = line.split(",");
                    radios.put(radio[0], Arrays.asList(radio));
                }
            }
        } catch (Exception e) {
            log.info("===>setupRadios-解析txt文件异常, errMsg={}<===", e.getMessage());
            e.printStackTrace();
        }
    }

    private void setupOperations() {
        operations = new HashMap<>();
        String[] pauses = {"暂停", "等一下", "稍等", "先停一下"};
        operations.put("PAUSE", Arrays.asList(pauses));
        String[] stops = {"不想听", "不要听", "不想要听", "不要说了","不要讲了", "别说了","停止", "停", "停下来", "停一下"};
        operations.put("STOP", Arrays.asList(stops));
    }

    public RadioProperties() {
        setupRadios();
        setupOperations();
    }


}
